package Base;

import java.io.InputStream;
import java.util.Properties;

/**
 * Created by Alain on 2016/3/16.
 */
public class PropertyUtil {
    public PropertyUtil(){
        super();
    }

    public static Properties resource = null;

    /**
     * load the test data in properties file
     * @param fileName : The relative path of the properties file
     * @return
     *
     */
    public static void loadPropertiesResources(String fileName)throws Exception{
        InputStream data_input = PropertyUtil.class.getResourceAsStream(fileName);
        resource = new Properties();
        try {
            resource.load(data_input);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String getInitialData(String dataName) {
        String dataId = null;
        try {
            PropertyUtil.loadPropertiesResources("/Base.properties");
            dataId = PropertyUtil.resource.getProperty(dataName);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataId;
    }
}
